package mint.modules.generator;

import java.util.Formatter;

import mint.modules.symbol.Symbol;
import mint.modules.symbol.SymbolTable;

public abstract class Scope {
	private SymbolTable table;
	private Scope parent;
	protected String containerClass;
	
	public Scope(Scope theParent, String theContainerClass)
	{
		table = new SymbolTable();
		parent = theParent;
		containerClass = theContainerClass;
	}
	
	public abstract void printSymbolTable(Formatter output, int tabSize);	
	
	public Symbol searchSymbol(String name, String innerClass, boolean isInheritance)
	{
		Symbol resp = table.getSymbol(name);
		
		if (resp != null)
			return resp;
		else
			if (parent != null)
				return parent.searchSymbol(name, innerClass, isInheritance);
			else
				return null;
	}
	
	public boolean addSymbol(Symbol symbol)
	{
		return table.addSymbol(symbol);			
	}
	
	public Scope getParent()
	{
		return parent;
	}
	
	public String getContainerClass()
	{
		return containerClass;
	}
}
